package com.example.baseweather;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.os.Handler;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class MyApplication extends Application {

    private static MyApplication myApplication;
    private static Handler mainHandler;
    private static ScheduledExecutorService mExecutorService;


    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
        mainHandler = new Handler(getMainLooper());
        mExecutorService = Executors.newScheduledThreadPool(4);
    }

    public static MyApplication getInstance() {
        return myApplication;
    }


    public static Context getContext() {
        return MyApplication.getInstance().getApplicationContext();
    }

    /**
     * 子线程切换主线程的方法
     */
    public static Handler getHandler() {
        return mainHandler;
    }


    public static ScheduledExecutorService getExecutorService() {
        return mExecutorService;
    }

}
